import { AfterViewChecked, Component, ElementRef, EventEmitter, Injector, Output, OnInit, ViewChild, Input } from '@angular/core';
import { AppConsts } from '@shared/AppConsts';
import { ActivatedRoute } from '@angular/router';
import { AppComponentBase } from '@shared/common/app-component-base';
import { ExecutionPointerDto, ProcessingContentApplyChangeMainDto, ProcessingContentApplyChangeServiceServiceProxy } from '@shared/service-proxies/service-proxies';
import { ModalDirective } from 'ngx-bootstrap';
import * as _ from 'lodash';
import { Paginator } from 'primeng/components/paginator/paginator';
import { Table } from 'primeng/components/table/table';
import { PrimengTableHelper } from 'shared/helpers/PrimengTableHelper';

@Component({
  selector: 'ProcessingContentApplyChangeDetail',
  templateUrl: './ProcessingContentApplyChangeDetail.component.html',
  styleUrls: ['./ProcessingContentApplyChangeDetail.component.css']
})
export class ProcessingContentApplyChangeDetailComponent extends AppComponentBase implements OnInit {
  @ViewChild('createOrEditModal') modal: ModalDirective;
  @ViewChild('paginator') paginator: Paginator;
  @ViewChild('dataTable') dataTable: Table;
  @ViewChild('recodedataTable') teskdataTable: Table;

  @Input() workflowid: any;
  @Output() out = new EventEmitter();

  active = false;
  saving = false;
  ProcessingContentApplyChangeDetailDto;
  _ProcessingContentApplyChangeMainDto: ProcessingContentApplyChangeMainDto = new ProcessingContentApplyChangeMainDto();
  detailsprimengTableHelper: PrimengTableHelper;
  constructor(injector: Injector,
    private route: ActivatedRoute,
    private _processingContentApplyChangeService: ProcessingContentApplyChangeServiceServiceProxy) {
    super(injector);
    this.detailsprimengTableHelper = new PrimengTableHelper();

  }
  ngOnInit(): void {

    console.log(this.workflowid);
    this.initForm();
  }
  initForm(): void {
    this._processingContentApplyChangeService.getProcessingContentApplyChange(this.workflowid).subscribe(dto => {
      this._ProcessingContentApplyChangeMainDto = dto.processingContentApplyChangeMainDto;
      this.ProcessingContentApplyChangeDetailDto = dto.processingContentApplyChangeDetailDtos;
      console.log(dto);
      this.primengTableHelper.totalRecordsCount = this.ProcessingContentApplyChangeDetailDto.length;
      this.primengTableHelper.records = this.ProcessingContentApplyChangeDetailDto;
      this.primengTableHelper.hideLoadingIndicator();
    });
  }
}


